<?php
class YuyueccAction extends Action
{
    //体检页面进行挂号
	public function guahao()
	{
       
         //P($_POST);die();
        //先接收数据
        //P($_POST);
        //姓名
        $requestArr['name'] = $_POST['name'];
         if (common_is_names($requestArr['name'])==null) {
        	$data['code'] = 4;

            $data['text'] = '姓名不对';
            die(json_encode($data));
        }
        //电话
        $requestArr['tel'] = $_POST['phone'];
    	if(common_is_mobile($requestArr['tel'])==null){
        	$data['code'] = 4;
            $data['text'] = '手机号码不对';
            die(json_encode($data));
        }
        //科室
        $requestArr['ks'] = $_POST['ks'];
        //预约时间
        $requestArr['yuyuedata'] = $_POST['yy_time'];
        //请求地址
        $requestArr['http_url'] = $_POST['url'];
        //请求IP
        $requestArr['dy_ip'] = $_SERVER['REMOTE_ADDR'];
        	
        	//邮箱发生action
        		//code为1为普通预约2为详细预约
			       $array_eamil = array(
			         'name' => $requestArr['name'],
			         'tel' => $requestArr['tel'],
			         'ks' =>  $requestArr['ks'],
			         'yuyuedata' => $requestArr['yuyuedata'],
			         'http_url' => $requestArr['http_url'],
			         'dy_ip' => $requestArr['dy_ip'],
			         );
        	$eamil_date=base64_encode(json_encode($array_eamil));
        	$eamil_url='http://eamilyuyue.zmshl.com/fy_yuyue.php?code=1&date='.$eamil_date;
        	file_get_contents($eamil_url);
			//邮箱发生END
			
        //实例化model
        $yuyueModel = new YuyueccModel();
		
        //插入数据
        $result = $yuyueModel->insert($requestArr);
        if ( $result > 0 )
        {
            $data['code'] = 1;

            $data['text'] = '预约成功';
        }
        else
        {
            $data['code'] = 0;

            $data['text'] = '预约失败';
        }

        die(json_encode($data));


	}
    //自主进行挂号
    public function zizhuguahao()
    {
        
        //先接收数据
        //姓名
        $requestArr['name'] = $_POST['name'];
          if (common_is_names($requestArr['name'])==null) {
        	$data['code'] = 4;

            $data['text'] = '姓名不对';
            die(json_encode($data));
        }
        
    	//电话
        $requestArr['tel'] = $_POST['phone'];
        if(common_is_mobile($requestArr['tel'])==null){
        	$data['code'] = 4;
            $data['text'] = '手机号码不对';
            die(json_encode($data));
        }
        
        //科室
        $requestArr['ks'] = $_POST['ks'];
        //预约时间
        $requestArr['yuyuedata'] = $_POST['yy_time'];
        if($requestArr['yuyuedata']==null){
        	$data['code'] = 4;
            $data['text'] = '预约时间没有填写';
            die(json_encode($data));
        }
        //性别
        $requestArr['sex'] = $_POST['sex'];
        //年龄
        $requestArr['gre'] = $_POST['age'];
        if(common_is_number($requestArr['gre'])==null){
        	$data['code'] = 4;
            $data['text'] = '年龄信息不对';
            die(json_encode($data));
        }
        //描述
        $requestArr['ag_cont'] = $_POST['description'];
        //请求地址
        $requestArr['http_url'] = $_POST['url'];
        //请求IP
        $requestArr['dy_ip'] = $_SERVER['REMOTE_ADDR'];
        	
        	//邮箱发生action
        		//code为1为普通预约2为详细预约
			       $array_eamil = array(
			         'name' => $requestArr['name'],
			         'tel' => $requestArr['tel'],
			         'ks' =>  $requestArr['ks'],
			         'yuyuedata' => $requestArr['yuyuedata'],
			         'sex' => $requestArr['sex'],
			         'gre' => $requestArr['gre'],
			         'ag_cont' => $requestArr['ag_cont'],
			         'http_url' => $requestArr['http_url'],
			         'dy_ip' => $requestArr['dy_ip'],
			         );
        	$eamil_date=base64_encode(json_encode($array_eamil));
        	$eamil_url='http://eamilyuyue.zmshl.com/fy_yuyue.php?code=2&date='.$eamil_date;
        	file_get_contents($eamil_url);
        	//邮箱发生END
        
        
        //实例化model
        $BlyuyueModel = new BlyuyueModel();

        //插入数据
        $result = $BlyuyueModel->insert($requestArr);
        if ( $result > 0 )
        {
            $data['code'] = 1;

            $data['text'] = '预约成功';
        }
        else
        {
            $data['code'] = 4;

            $data['text'] = '预约失败';
        }

        die(json_encode($data));


    }


	

}
?>